﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Control_UpdateControl : System.Web.UI.UserControl
{
    private String getprocate = null;
    protected void Page_Load(object sender, EventArgs e)
    {
         getprocate = Request.QueryString["idprocate"].ToString();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            String kn = "Data Source=WIN7-PC;Initial Catalog=UPDATEDB;User ID=sa;Password=1234567";// chuoi kn
            SqlConnection con = new SqlConnection(kn);
            //con.ConnectionString = ConfigurationManager.ConnectionStrings["Ketnoi"].ConnectionString;
            con.Open();
            SqlCommand com = con.CreateCommand();
            com.CommandType = CommandType.Text;
            com.CommandText = "UPDATE EX Set NAME='"+ TextBox1.Text + "' where ID = " + int.Parse(TextBox2.Text)  ;//cau lenh sql
            int ressut = com.ExecuteNonQuery();
            if (ressut == 1)
            {
                Response.Redirect("Default2.aspx");
            }
            else
            {
                Response.Write("Default3.aspx");
            }
            con.Close();
        }
        catch (SqlException ex)
        {
            ex.ToString();
            throw;
        }
    }
}